import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2022-12-17
 * Time: 13:11
 */
public class Main {
    public static String[] shapes;//这个数组存储都有那些形状

    /**
     * 读取配置文件中的形状
     * @param url
     * @throws IOException
     */
    public static void readShapes(String url) throws IOException {
        BufferedReader bufferedReader=new BufferedReader(new FileReader(new File(url)));
        String str;
        if((str=bufferedReader.readLine()).equals("[Painter]")){
            String shape=bufferedReader.readLine();
            //先将key和value分隔
            String[] keyValue=shape.split("=");
            if(keyValue[0].equals("Shapes")){
                //再将一个个value分开
                shapes=keyValue[1].split(",");
            }
        }
        for (String s: shapes) {
            System.out.println(s);
        }
    }
    public static void main(String[] args) {
        try {
            //从配置文件中读取都需要哪些形状
            readShapes(args[0]);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        //进入画图程序
        MyPanel.init(shapes);

    }
}
